/**
 * title: 组织
 */

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types'
import { connect } from 'dva';
import { Button, Tabs, Row, Col } from 'antd';
import Myorganiza from './orgmanage/myorganiza'
import RoleIndex from './rolepermissions/roleIndex'

import OrganizationTree from './components/OrganizationTree'

const TabPane = Tabs.TabPane;


@connect(({ loading, dispatch, app, role }) => ({
  app,
  role,
  // reloading: loading.effects['role/getRoleList'],
}))
// @Form.create()

class MyPage extends PureComponent {

  callback = (key) => {
    const { dispatch, app: { singleOriginal } } = this.props
    // console.log(key, singleOriginal);
    switch (key) {
      case "2":
        dispatch({
          type: 'role/getRoleList',
          payload: {
            orgId: singleOriginal.id,
            pageNum: 1,
            pageSize: 10,
          }
        })
        break;
    }
  }

  componentDidMount() {
    const { dispatch } = this.props
  }

  render() {
    const { app: { singleOriginal } } = this.props
    return (
      <React.Fragment>
        <h1>{singleOriginal.name || "XXXX集团 / 公司"}</h1>
        <Row>
          <Col span={5}>
            <OrganizationTree />
          </Col>
          <Col offset={1} span={18}>
            <Tabs defaultActiveKey="1" onChange={this.callback}>
              <TabPane tab="组织管理" key="1"><Myorganiza /></TabPane>
              <TabPane tab="权限角色" key="2"><RoleIndex /></TabPane>
            </Tabs>
          </Col>
        </Row>
        {/* <Button type="primary" onClick={onClick}>点我后，查看打开控制台</Button> */}
      </React.Fragment>
    );
  }
};

export default MyPage

